#pragma once
#include "module/plugins/main_plugins_base.h"
#include "gui/cef/cef_wallet.h"
#include "gui/cef/cef_form.h"

class WalletPlugin : public nim_comp::MainPluginBase<nim_comp::IMainPlugin::PluginType::PluginType_Simple>
{
public:
	WalletPlugin() {};
	virtual ~WalletPlugin() = default;
	virtual PluginFlagType GetPluginFlag() const override
	{
		return "WalletPlugin";
	}
public:
	virtual bool IsEnabled() { return true; }
	virtual bool IsActivePage() const { return false; }
	virtual void DoInit() override
	{
		auto goto_wallet = dynamic_cast<ui::ButtonBox*>(icon_->FindSubControl(L"goto_wallet"));
		if (goto_wallet) {
			goto_wallet->AttachClick(goto_wallet->ToWeakCallback([](ui::EventArgs* param) {
				nim_ui::WindowsManager::GetInstance()->SingletonShow<CefForm>(CefForm::kClassName, false, L"cefbrowser/cef_wallet.xml", new CefWallet);
			return true;
				}));
		}
	}
protected:
	virtual ui::OptionBox* CreatePluginIcon() override
	{
		auto ret = new nim_comp::MainPluginIcon;
		ui::GlobalManager::FillBoxWithCache(ret, L"plugins/wallet/icon.xml");
		return ret;
	}
	virtual ui::Box* CreatePluginPage() override
	{
		return nullptr;
	}
};